﻿using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using NHibernate.Mapping.Attributes;
using Lib;

namespace Persistance.Model
{
    [Serializable]
    [Class(Lazy = true)]
    public class ItemType
    {

        /// <summary>
        /// This is needed for NH. NH only accepts numeric primary keys
        /// </summary>
        private int _itemTypeID;
        //NHIBER: Setts the primary key to ID
        [Id(Name = "ItemTypeID")]
        [Generator(1, Class = "native")]
        public virtual int ItemTypeID
        {
            get { return _itemTypeID; }
            set { _itemTypeID = value; }
        }

        private string _typeName;
        [Property(Length = 500)]
        public virtual string TypeName
        {
            get { return _typeName; }
            set { _typeName = value; }
        }

        private IList<Items> _items = new List<Items>();
        [Bag(1, Inverse = true)]
        [Key(2, Column = "ItemID", ForeignKey = "ItemToItemType")]
        [OneToMany(3, ClassType = typeof(Items))]
        public virtual IList<Items> Items
        {
            get { return _items; }
            set { _items = value; }
        }

    }
}
